<?php
class Login extends CI_Controller{
	//构造函数
	function __construct(){
		parent::__construct();
	
		
		$this->load->library('ChromePhp');

		//是否又提交验证
		if( !empty($_POST['user_account']) && !empty($_POST['user_password'])){
			$this -> load -> model('User');
			$return_query = $this -> User -> Login($_POST['user_account'],$_POST['user_password']);
			if( $return_query  != false ){
				//设定user_session数据
				$user_session_array = array(
						'user_id' => $return_query->row()->uid,
						'user_account' => $return_query->row()->user_account,
						'user_password' => $return_query->row()-> user_password
				);				
				$this->session->set_userdata($user_session_array);
				
				$this->load->helper('url');
				redirect('/Home');
			}
		}
	}
	
	//首页
	public function  Index () {
		$this-> load -> view('login');
	}
}
